home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9761 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  44 lines

  1. Newsgroups: comp.lang.c
  2. Path: news.prima.ruhr.de!oscar!patrick
  3. From: patrick@oscar.prima.ruhr.de (Patrick Mau)
  4. Subject: Quotes in C comments
  5. X-Newsreader: TIN [version 1.2 PL2]
  6. Organization: Private Linux Site ( Prima e.V )
  7. Message-ID: <Do6nn5.5rE@oscar.prima.ruhr.de>
  8. Date: Wed, 13 Mar 1996 01:47:29 GMT
  9.  
  10. Hi there,
  11.  
  12. I had a really funny problem with quotes in C programs:
  13.  
  14. The question is:
  15.  How should a compiler handle the following comments
  16.  
  17. First Example:
  18.  
  19. /*
  20.  *  printf( "/* funny printf */" );
  21.  *                           ^^--- Point A
  22.  */
  23.  
  24. Second Example:
  25.  
  26.  /*
  27.   *  You can't do xyz here
  28.   *         ^--- Point B
  29.   */
  30.  
  31. In the first example the compiler could stop at point A thinking the
  32. comment ends at that point. This would be the case if the compiler
  33. doesn't check quotes within comments. ( they are usually ignored. )
  34.  
  35. In the second example ( _that_ happened to me with gcc 2.7.2 )
  36. the compiler complains about an unterminated character constant
  37. at EOF and says it could be at point B.
  38.  
  39. How should a good compiler handle those kinds of comments.
  40. Should it check for quotes within comments or not ?
  41.  
  42.         Best regards ...
  43.              ... Patrick
  44.